package pers.muci.flowableable;

import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

/**
 * 1.创建并暴露 ProcessEngine CmmnEngine DmnEngine FormEngine ContentEngine IdmEngine
 * 2.将所有flowable服务暴露成 spring bean
 * 3.创建了Spring Job Executor
 * 4.processes目录下的任何BPMN 2.0流程定义都会被自动部署。
 * 5.forms目录下的任何Form定义都会被自动部署。
 * 6.cases目录下的任何CMMN 1.1事例都会被自动部署。
 */
@SpringBootApplication
public class FlowableAbleApplication {

    public static void main(String[] args) {
        SpringApplication.run(FlowableAbleApplication.class, args);
    }

    @Bean
    public CommandLineRunner init(final RepositoryService repositoryService,
                                  final RuntimeService runtimeService,
                                  final TaskService taskService){
        return new CommandLineRunner() {
            @Override
            public void run(String... args) throws Exception {
                System.out.println(repositoryService.createProcessDefinitionQuery().count());
                System.out.println(taskService.createTaskQuery().count());
            }
        };
    }

}
